
Ext.define('EvaluationApp.model.EvaluationModel', {
	extend : 'Ext.data.Model',
	fields : [
		{name : 'date',  		type : 'string'},
		{name : 'year', 		type : 'string', 
			convert : function(v, record){
				return dateField.getYear(record.data.date);
			}
		},
		{name : 'month', 		type : 'string', 
			convert : function(v, record){
				return dateField.getMonth(record.data.date);
			}
		},
		{name : 'score', 		type : 'string'},
		{name : 'credit', 	type : 'string'}
		
	],
	idProperty : 'evalModel'
});

var dateField = function(){
	return {
		getYear : function(date){
			if(date.length >= 5)	return parseInt(date.substring(0, 3))+1900;
			else return parseInt(date.substring(0, 2))+1900;
		},
		getMonth : function(date){
			if(date.length >= 5)	return date.substring(3, 5);
			else return date.substring(2, 4);
		}
	};
}();
